package presenter.delete;

import main.InputBean;
import utils.OnLogListener;
import utils.FileBean;
import utils.FileFilter;
import utils.TextUtils;

import java.util.List;

public class FileDeletor {

    public static void del(InputBean info, OnLogListener listener) {
        String path = info.path1();
        String fileName = info.path2();
        List<FileBean> items = FileFilter.filter(true, false, true, path, name -> TextUtils.equals(name, fileName));
        listener.log(String.format("共收集到 %d 个同名文件，开始删除操作...", items.size()));
        for (FileBean item : items) {
            item.del(listener);
        }
        listener.taskFinish();
    }
}
